<?php 
class branch_Form_FrmBranch extends Zend_Form
{
	public function frmBranch($frm = null)
    {
    	$location = new Zend_Form_Element_Select('location');
    	$location->setAttribs(array(
    		'class'=>'form-control chzn-select validate[required]'
    	));
    	$db = new Application_Model_DbTable_DbGlobal();
    	$rs = $db->getLocation();
    	$opt = array(''=>'ជ្រើសរើស ខេត្ត ក្រុង/Choose Location');
    	foreach ($rs as $data){
    		$opt[$data["location_id"]] = $data["location_name"];
    	}
    	$location->setMultiOptions($opt);
    	
    	$branch = new Zend_Form_Element_Text('branch');
    	$branch->setAttribs(array('class'=>'form-control validate[required]',));
    		
    	$status = new Zend_Form_Element_Select('status');
    	$status->setAttribs(array('class'=>'form-control validate[required]'));
    	$opt_status = array(''=>'ជ្រើសរើស ស្ថានភាព','1'=>'ប្រើប្រាស់','0'=>'មិនប្រើប្រាស់');
    	$status->setMultiOptions($opt_status);
    	
    	$address = new Zend_Form_Element_Textarea("address");
    	$address->setAttribs(array('class'=>'form-control'));
    	
    	$description = new Zend_Form_Element_Textarea("description");
    	$description->setAttribs(array('class'=>'form-control'));
    		
    	$id = new Zend_Form_Element_Hidden('id');
    	$this->addElements(array($location,$branch,$status,$address,$description,$id));    	
    	if($frm){
    		$id->setValue($frm['branch_id']);
    		$branch->setValue($frm["branch_name"]);
    		$location->setValue($frm["location_id"]);
    		$address->setValue($frm["branch_address"]);
    		$status->setValue($frm["status"]);
    		$description->setValue($frm["description"]);
    		
    	}
    	return $this;
     }
}
?>
